<?php error_reporting (E_ALL ^ E_NOTICE);   // Remove unneeded notices ?> 

<?php
session_start();
include ('mysqlfunctions.php');
?>

    <!DOCTYPE html>

    <html>
    <head>
        <title>Post Book Form</title>
        <!-- Bootstrap -->
        <link href="css/bootstrap.css" rel="stylesheet">
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <link href="css/docs.css" rel="stylesheet">
        <script src="js/infogenerate.js"></script>
        <style type="text/css">
          body {
            font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
            font-size:12px;
          }

          /* Box Style */

          body {
              font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
              font-size:12px;
            }

            fieldset {
              background:#EBF4FB none repeat scroll 0 0;
              border:2px solid #B7DDF2;
              width: 500px;
            }
            legend {
              color: #fff;
              background: #80D3E2;
              border: 1px solid #781351;
              padding: 2px 6px
            }

            p {
              border-bottom:1px solid #B7DDF2;
              color:#666666;
              font-size:11px;
              margin-bottom:20px;
              padding-bottom:10px;
            }

            a{
                color:#0099FF;
            font-weight:bold;
            }

           .success, .warning, .errormsgbox, .validation {
            border: 1px solid;
            margin: 0 auto;
            padding:10px 5px 10px 50px;
            background-repeat: no-repeat;
            background-position: 10px center;
               font-weight:bold;
               width:450px;
               
          }

          .errormsgbox {
           
            color: #D8000C;
            background-color: #FFBABA;
            background-image: url('img/error.png');
            
          }

        </style>
    </head>
<?php if(isset($_SESSION['myusername'])) { // Check to see if user is logged in
?> 
    <body>
        <div class="navbar navbar-fixed-top">
          <div class="navbar-inner">
            <div class="container-fluid">
              <a class="brand" href="#"><?php echo $_SESSION['myusername'] ?></a>
              <div class="nav-collapse collapse">
                <ul class="nav">
                  <li><a href="logout.php">Logout</a></li>
                </ul>
              </div>
            </div>
          </div>
        </div>
        <br>
        <canvas id="title" width="1390" height="90"></canvas>
            <script>
              var canvas = document.getElementById('title');
              var context = canvas.getContext('2d');
              var x = canvas.width / 2;
              var y = canvas.height / 2;

              context.font = 'bold 30pt Calibri';
              context.textAlign = 'center';
              context.fillText('Post your Book', x, y);
            </script>
        <div class="container" >
            
            <form id="book_form" action="bookinfo.php" method="post">

                <div class="row">
                    <div class="span4 offset3">
                        <label> Book (*): </label>
                        <input type="text" id="book" name="book"  width="30" height="30" required>
                         
                        <label> Author: </label>
                        <input type="text" id="author" name="author">

                        <label> ISSN: </label>
                        <input type="text" id="issn" name="issn">

                        <label> Edition: </label>
                        <input type="text" id="edition" name="edition">

                        <label> Image URL: </label>
                        <input type="text" id="image" name="image">

                    </div>

                    <div class="span4">
                        <label> Class (*): </label>
                        <input type="text" id="class" name="class" pattern="[^\s]+-\d{3}" placeholder="ICS-101" required >

                        <label> Professor: </label>
                        <input type="text" id="professor" name="professor">

                        <label> PRICE (*): </label>
                        <input type="text" id="price" name="price" pattern="\d+\.\d{2}" placeholder="XX.XX" required>

                        <label> Description: </label>
                        <textarea id="description" name="description"></textarea>
                    </div>
                </div>
                <br>
                <div class ="span4 offset4">
                    <input class="btn btn-large btn-block btn-primary" type="submit" />
                </div>
            </form>
            <canvas id="footer" width="970" height="100"></canvas>
            <script>
              var canvas = document.getElementById('footer');
              var context = canvas.getContext('2d');
              var x = canvas.width / 2;
              var y = canvas.height / 2;

              context.font = 'italic 12pt Calibri';
              context.textAlign = 'center';
              context.fillText('*Required', x, y);
            </script>
        </div> <!-- /container -->
    </body>
    <?php
    } else {
        echo "<body><center><fieldset>
         
            <div class=\"errormsgbox\">
            <strong> Error. </strong><br>
            Please log in first to post a book. 
            </div>
        </fieldset></center></body>";
        header("refresh:10;url=index.php");
    }
?>
    </html>
